1. /* sifdivnw.cpp by K.Tsuru */
  2. // function ID = 427 BRADIX
  3. /**************************************************************
  4. SInteger class's friend function.
  5. It provides the quotient m/n and remainder m%n.
  6. The Newton'method division is used after the radix conversion
  7. to SLong.It is not so fast because the radix conversion spends
  8. time.
  9. ***************************************************************/
  10. #ifndef SN_H
  11. #include "sn.h"
  12. #endif
  13. void NewtonIIDiv(const SInteger& m, const SInteger& n, Ldiv_t& r, bool needRem){
  14. SLong M, N;
  15. int dm = M.LLDivMode();
  16. M = m.ConvToDec(); N = n.ConvToDec(); //radix conversion
  17. M.UseNewtonLLDiv();
  18. r = LLDiv(M, N, needRem);
  19. /*
  20. A statement
  21. r.rem=ConvToBin(r.quot);
  22. cannot be used, because it is interpreted as the substitution "SLong=SInteger".
  23. Then the constructor of "Ldiv_t" structure is used.
  24. */
  25. SInteger tmp; // version 2.20
  26. if(needRem) r = Ldiv_t( tmp.ConvToBin(r.quot), tmp.ConvToBin(r.rem) ); //inverse conversion
  27. else r = Ldiv_t( tmp.ConvToBin(r.quot) );
  28. if(dm == M.Knuth) M.UseKnuthLLDiv();
  29. }

sifdivnw.cpp : last modifiled at 2016/08/03 16:32:36(1,079 bytes)
created at 2016/04/25 14:53:17
The creation time of this html file is 2017/10/25 11:09:45 (Wed Oct 25 11:09:45 2017).